
#include "SparkEditorFrame.h"
#include "SparkEditorResource.h"

#include "SparkEditorMenuFile.h"
#include "SparkEditorMenuEdit.h"
#include "SparkEditorMenuTools.h"
#include "SparkEditorMenuView.h"
#include "SparkEditorMenuMessages.h"
#include "SparkEditorMenuCamera.h"
#include "SparkEditorMenuTerrainTools.h"
#include "SparkEditorMenuHelp.h"

#include "SparkEditorNotebookExplorer.h"
#include "SparkEditorNotebookProperty.h"
#include "SparkEditorNotebookConsole.h"
#include "SparkEditorNotebookGraphic.h"
#include "SparkEditorNotebookToolBar.h"

#include "SparkEditorPanelSceneView.h"

#include "wxOgreViewXML.h"

BEGIN_EVENT_TABLE(SparkEditorFrame, wxFrame)
	EVT_MENU(IDMENU_HELP_ABOUT, SparkEditorFrame::OnAbout)
END_EVENT_TABLE()

namespace Ogre
{
	extern void OfsdllStartPlugin(void);

	extern void OfsdllStopPlugin(void);
};

SparkEditorFrame::SparkEditorFrame()
{
}

SparkEditorFrame::SparkEditorFrame(wxWindow *parent,
	wxWindowID id,
	const wxString& title,
	const wxPoint& pos,
	const wxSize& size,
	long style,
	const wxString& name)
	: wxFrame(parent, id, title, pos, size, style, name)
{
	m_AuiManager.SetManagedWindow(this);

	// create a menu bar
	SparkEditorMenuFile *fileMenu = new SparkEditorMenuFile;
	fileMenu->SetSparkEditorFrame(this);
	fileMenu->ConnectEvent();

	SparkEditorMenuEdit *editMenu = new SparkEditorMenuEdit;
	editMenu->SetSparkEditorFrame(this);
	editMenu->ConnectEvent();

	SparkEditorMenuTools *toolsMenu = new SparkEditorMenuTools;
	toolsMenu->SetSparkEditorFrame(this);
	toolsMenu->ConnectEvent();

	SparkEditorMenuView *viewMenu = new SparkEditorMenuView;
	viewMenu->SetSparkEditorFrame(this);
	viewMenu->ConnectEvent();

	SparkEditorMenuMessages *messagesMenu = new SparkEditorMenuMessages;
	messagesMenu->SetSparkEditorFrame(this);
	messagesMenu->ConnectEvent();

	SparkEditorMenuCamera *cameraMenu = new SparkEditorMenuCamera;
	cameraMenu->SetSparkEditorFrame(this);
	cameraMenu->ConnectEvent();

	SparkEditorMenuTerrainTools *terraintoolsMenu = new SparkEditorMenuTerrainTools;
	terraintoolsMenu->SetSparkEditorFrame(this);
	terraintoolsMenu->ConnectEvent();

	SparkEditorMenuHelp *helpMenu = new SparkEditorMenuHelp;
	helpMenu->SetSparkEditorFrame(this);
	helpMenu->ConnectEvent();

	wxMenuBar* menuBar = new wxMenuBar();
	menuBar->Append(fileMenu, "&File");
	menuBar->Append(editMenu, "&Edit");
	menuBar->Append(toolsMenu, "&Tools");
	menuBar->Append(viewMenu, "&View");
	menuBar->Append(messagesMenu, "&Messages");
	menuBar->Append(cameraMenu, "&Camera");
	menuBar->Append(terraintoolsMenu, "&Terrain Tools");
	menuBar->Append(helpMenu, "&Help");

	SetMenuBar(menuBar);


	// create a status bar just for fun (by default with 1 pane only)
	CreateStatusBar(2);
	SetStatusText("Welcome to wxWidgets!");
	SetStatusText("Welcome to wxWidgets!!", 1);

	SparkEditorNotebookToolBar* notebookToolBar = new SparkEditorNotebookToolBar(this, IDNOTEBOOK_PANEL_EXPLORER, wxDefaultPosition, wxDefaultSize, wxAUI_NB_BOTTOM | wxNO_BORDER);
	notebookToolBar->SetName(wxT("ToolBar"));
	m_AuiManager.AddPane(notebookToolBar, wxAuiPaneInfo()
		.Name(wxT("ToolBarPanel")).Top().Layer(1).BestSize(wxSize(200, 200)).FloatingSize(wxSize(512, 512)).Caption(wxT("ToolBar")).Resizable(true).Gripper(true).GripperTop(true).PinButton(true));

	SparkEditorNotebookExplorer* notebookExplorer = new SparkEditorNotebookExplorer(this, IDNOTEBOOK_PANEL_EXPLORER, wxDefaultPosition, wxDefaultSize, wxAUI_NB_BOTTOM | wxNO_BORDER);
	notebookExplorer->SetName(wxT("Explorer"));
	m_AuiManager.AddPane(notebookExplorer, wxAuiPaneInfo()
		.Name(wxT("ExplorerPanel")).Left().Layer(1).BestSize(wxSize(200, 200)).FloatingSize(wxSize(512, 512)).Caption(wxT("Explorer")).Resizable(true).Gripper(true).GripperTop(true).PinButton(true));

	SparkEditorNotebookProperty* notebookProperty = new SparkEditorNotebookProperty(this, IDNOTEBOOK_PANEL_PROPERTIES, wxDefaultPosition, wxDefaultSize, wxAUI_NB_BOTTOM | wxNO_BORDER);
	notebookProperty->SetName(wxT("Property"));
	m_AuiManager.AddPane(notebookProperty, wxAuiPaneInfo()
		.Name(wxT("PropertyPanel")).Right().Layer(1).BestSize(wxSize(200, 200)).FloatingSize(wxSize(512, 512)).Caption(wxT("Property")).Resizable(true).Gripper(true).GripperTop(true).PinButton(true));

	SparkEditorNotebookConsole* notebookConsole = new SparkEditorNotebookConsole(this, IDNOTEBOOK_PANEL_PROPERTIES, wxDefaultPosition, wxDefaultSize, wxAUI_NB_BOTTOM | wxNO_BORDER);
	notebookConsole->SetName(wxT("Console"));
	notebookConsole->ConnectEvent();
	m_AuiManager.AddPane(notebookConsole, wxAuiPaneInfo()
		.Name(wxT("ConsolePanel")).Bottom().Layer(1).BestSize(wxSize(200, 200)).FloatingSize(wxSize(512, 512)).Caption(wxT("Console")).Resizable(true).Gripper(true).GripperTop(true).PinButton(true));

	
	SparkEditorNotebookGraphic* notebookGraphic = new SparkEditorNotebookGraphic(this, IDNOTEBOOK_PANEL_PROPERTIES, wxDefaultPosition, wxDefaultSize, wxAUI_NB_BOTTOM | wxNO_BORDER);
	notebookGraphic->SetName(wxT("Graphic"));
	notebookGraphic->ConnectEvent();
	m_AuiManager.AddPane(notebookGraphic, wxAuiPaneInfo()
		.Name(wxT("GraphicPanel")).Center().Layer(1).BestSize(wxSize(200, 200)).FloatingSize(wxSize(512, 512)).Caption(wxT("Graphic")).Resizable(true).Gripper(true).GripperTop(true).PinButton(true));

	m_AuiManager.Update();
}

SparkEditorFrame::~SparkEditorFrame()
{

}



bool SparkEditorFrame::Close(bool force)
{
	return	wxFrame::Close(force);
}

void SparkEditorFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
	wxMessageBox(wxString::Format
		(
		"Welcome to %s!\n"
		"\n"
		"This is the minimal wxWidgets sample\n"
		"running under %s.",
		wxVERSION_STRING,
		wxGetOsDescription()
		),
		"About wxWidgets minimal sample",
		wxOK | wxICON_INFORMATION,
		this);
}